$package('jeecg.TostPjMempushmoney');

$("#pjid").ready(function (){
	$.ajax({
		url:"getProject.do",
		dataType:'json',
		success:function (result){
			var str="<option></option>";
			for(var i=0;i<result.length;i++){
				str+="<option value='"+result[i].id+"'>"+result[i].pjProjectname+"</option>";
			}
			str+="</select>";
			document.getElementById("pjid").innerHTML=str;
		}
	});
})

function subSearchFrom(){
	var pjid = document.getElementById("pjid").value;
	if(pjid!=null&&pjid!=""){
		requestAjax();
	}
	else
		alert("请选择项目");
}

function requestAjax(){
	$("#dataTab").html("");
	$.ajax({
		url:"dataList.do",
		data:$("#searchForm").serialize(),
		dataType:'json',
		success:function(result){
			var str = "";
			if(result.months.length>0){
				str+="<tr class='tabhead'><td style=\"width:120\">姓名</td>";
				for(var m = 0;m<result.months.length;m++){
					str+="<td style=\"width:120\">"+result.months[m]+"</td>";
				}
				str+="<td style=\"width:120\">合计</td></tr>";
			}
			for(var i = 0;i < result.listSize;i++){
				var countPay = 0;
				str+="<tr>";
				for(var j = 0;j < result["dataList_"+i].length;j++){
					countPay += result["dataList_"+i][j].mpmPycount;
					if(j==0)
						str += "<td style=\"width:120\">"+result["dataList_"+i][j].hrName+"</td>";
					str += "<td>"+result["dataList_"+i][j].mpmPycount+"</td>";
					if(j==result["dataList_"+i].length-1)
						str += "<td style=\"width:120\">"+countPay+"</td>";
				}
				str += "</tr>";
			}
			$("#dataTab").html(str);
		}
	});
}